# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=eog
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.16.3
pkgrel=1
arch=('any')
pkgdesc="Eye of GNOME graphics viewer program (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
         "${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection-runtime"
         "${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
         "${MINGW_PACKAGE_PREFIX}-zlib"
         "${MINGW_PACKAGE_PREFIX}-libexif"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-libpeas"
         "${MINGW_PACKAGE_PREFIX}-librsvg"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-shared-mime-info")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "gtk-doc")
options=('strip' 'staticlibs')
license=("GPL 2")
url="https://www.gnome.org"
install=eog-${CARCH}.install
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-$pkgver.tar.xz
        001-win.patch
        002-relocation-support.patch
        003-fix-install-dirs.patch
        004-give-cc-to-gir-scanner.mingw.patch)
sha256sums=('ee6d101f8e73aacc8d48256f06a780c6d0d5f3975990f375f58cd0e70816b766'
            '31db56ea4d64059e60c478a7ba1475d9beaf65f2c42967909adbb41843c2d129'
            'a7e897da94d7033fd2ad4d81129f7a60cd0f68bd8d887c079c79cef802d02a4d'
            'abc9df56f5fc2213ba6efdcdad269534496d6eda900194b4000910dacf4042d9'
            '8fd79bb5f0e411d682abd7cffa3b9b8476cf8a073ea17c2e0bd1a386e3b060e0')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/001-win.patch
  patch -p1 -i ${srcdir}/002-relocation-support.patch
  patch -p1 -i ${srcdir}/003-fix-install-dirs.patch
  patch -p1 -i ${srcdir}/004-give-cc-to-gir-scanner.mingw.patch

  autoreconf -isf
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p doc/reference/html
  cp -rf ../${_realname}-${pkgver}/doc/reference/html/* doc/reference/html

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-introspection \
    --without-cms \
    --without-x

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
